import { create } from "zustand";
import { persist, createJSONStorage } from "zustand/middleware";

interface LoginState {
  token: string;
  setToken: (token: string) => void;
}

const useLoginStore = create<LoginState>()(
  persist(
    (set) => ({
      token: "",
      setToken: (token) => set({ token }),
    }),
    {
      name: "LOGIN_STORAGE",
      storage: createJSONStorage(() => localStorage),
    }
  )
);

export default useLoginStore;
